/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.com.controller;

import br.com.biblioteca.common.util.CpfUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.com.model.Cliente;

/**
 *
 * @author Afonso Rodrigues
 */
public class BaseCliente {

    private List<Cliente> clientes;

    public BaseCliente() {
        this.clientes = new ArrayList<>();
        CpfUtils cU = new CpfUtils();
        this.clientes.add(new Cliente(1, "Fulano", cU.geraCpfValido(), "Rua A", "teste.aplicacao@gmail.com", 12233456, "fulano", "fulano"));
        this.clientes.add(new Cliente(2, "Ciclano", cU.geraCpfValido(), "Rua B", "teste.aplicacao@gmail.com", 12233456, "ciclano", "ciclano"));
        this.clientes.add(new Cliente(3, "Fulano1", cU.geraCpfValido(), "Rua A", "teste.aplicacao@gmail.com", 12233456, "fulano1", "fulano1"));
        this.clientes.add(new Cliente(4, "Fulano2", cU.geraCpfValido(), "Rua A", "teste.aplicacao@gmail.com", 12233456, "fulano2", "fulano2"));
        this.clientes.add(new Cliente(5, "Fulano3", cU.geraCpfValido(), "Rua A", "teste.aplicacao@gmail.com", 12233456, "fulano3", "fulano3"));
        this.clientes.add(new Cliente(6, "Fulano4", cU.geraCpfValido(), "Rua A", "teste.aplicacao@gmail.com", 12233456, "fulano4", "fulano4"));
        this.clientes.add(new Cliente(7, "Fulano5", cU.geraCpfValido(), "Rua A", "teste.aplicacao@gmail.com", 12233456, "fulano5", "fulano5"));
        this.clientes.add(new Cliente(8, "Fulano6", cU.geraCpfValido(), "Rua A", "teste.aplicacao@gmail.com", 12233456, "fulano6", "fulano6"));
    }

    public void addCliente(Cliente cliente) {
        clientes.add(cliente);
    }

    public void removeCliente(Cliente cliente) {
        clientes.remove(cliente);
    }

    public Cliente getCliente(int idClient) {
        Cliente cliente = new Cliente();
        boolean encontrado = false;
        for (Iterator it = clientes.iterator(); it.hasNext();) {
            Cliente cli = (Cliente) it.next();
            if (idClient == cli.getIdCliente()) {
                encontrado = true;
                cliente = cli;
            }
        }

        if (encontrado == true) {
            return cliente;
        } else {
            return null;
        }
    }

    public List getClientes() {
        return clientes;
    }

    public void setClientes(List clientes) {
        this.clientes = clientes;
    }

   
}
